package com.jiuyin.dianjing.api.helper;

import android.annotation.SuppressLint;
import android.content.Context;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.jiuyin.dianjing.api.base.BaseApiHelper;
import com.jiuyin.dianjing.api.data.BasicResponse;
import com.jiuyin.dianjing.api.enums.ApiEnum;
import com.jiuyin.dianjing.api.interfaces.TransApiResultListener;
import com.jiuyin.dianjing.api.loader.ApiLoader;
import com.jiuyin.dianjing.api.retrofit.RetrofitBasicResponseObserver;
import com.jiuyin.dianjing.app.HelperApplication;
import com.jiuyin.dianjing.model.CommentItemModel;
import com.jiuyin.dianjing.model.CommentModel;
import com.jiuyin.dianjing.model.GameDetailModel;
import com.jiuyin.dianjing.model.GameInfoItemModel;
import com.jiuyin.dianjing.model.MatchGameItemModel;
import com.jiuyin.dianjing.model.PostModel;
import com.jiuyin.dianjing.model.SettingBasicInfo;
import com.jiuyin.dianjing.util.GSonUtil;
import com.jiuyin.dianjing.util.LogUtil;
import com.jiuyin.dianjing.util.ToastUtil;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Observer;

import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_ADVERTISING_LINK;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_ANTISTOP_LIST;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_CHECK_CODE;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_CLICK_NUM;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_COMMENT_LIST;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_COMMENT_NUM;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_CONTENT;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_CREATE_TIME;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_GAME_ID;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_GAME_LIST;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_HEADER;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_HEAD_URL;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_HX_NICK_NAME;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_INFORMATION_COMMENT_ID;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_INFORMATION_ID;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_INFORM_LIST;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_INFOR_COMMENT;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_INTRO;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_LOGO;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_NAME;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_NICK_NAME;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_SRC;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_SRC_LIST;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_THUMB;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_THUMB_NUM;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_TITLE;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_TOKEN;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_TOPIC_LIST;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_TYPE;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_URL;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_USER;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_WORD;
import static com.jiuyin.dianjing.api.constant.ApiConstant.KEY_WORDS;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_ALL_INFORMATION_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_CANCEL_THUMB_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_CHECK_SMS_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_COMMENT_INFORMATION_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_CREATE_COMPETITION_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_CREATE_TEAM;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_GET_NAME_TITLE_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_GET_ORDER_WORDS_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_GET_SEARCH_BYWORD_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_GET_TOPIC_LIST;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_GET_USER_ATTENTION_LIST_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_GET_USER_COLLECT_LIST_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_GET_VIEW_PAGE_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_INFORMATION_DETAIL_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_LOGIN_WITH_CODE_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_LOGIN_WITH_PWD_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_MY_COMPETITION_GAME_LIST_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_MY_INFORMATION_DETAIL_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_REGISTER_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_SEND_SMS_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_THUMB_API;
import static com.jiuyin.dianjing.api.enums.ApiEnum.APP_USER_PWD_SET_API;
import static com.jiuyin.dianjing.constant.AppConstant.KEY_JG_NICKNAME;
import static com.jiuyin.dianjing.constant.AppConstant.KEY_JG_PASSWORD;
import static com.jiuyin.dianjing.constant.AppConstant.KEY_JG_USERNAME;


/**
 * The type Api helper.
 *
 * @author Administrator
 */
public class ApiHelper extends BaseApiHelper {

    /**
     * Gets instance.
     *
     * @param context the context
     * @return the instance
     */
    public static ApiHelper getInstance(Context context) {
        Holder.M_HELPER.setContext(context);
        return Holder.M_HELPER;
    }

    private ApiLoader getApiLoader() {
        if (mApiLoader == null) {
            mApiLoader = new ApiLoader();
        }
        return mApiLoader;
    }

    /**
     * 密码登陆
     *
     * @param listener | 回调
     */
    public void appLoginWithPwdApi(final String content,
                                   final TransApiResultListener<Boolean> listener) {
        getApiLoader().postStrObserveJson(APP_LOGIN_WITH_PWD_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appLoginWithPwdApi onSuccess");
                JsonObject jsonObject = response.getData();
                if (null != jsonObject) {
                    try {
                        LogUtil.log("appLoginWithPwdApi onSuccess = " + jsonObject.toString());
                        String token = jsonObject.get(KEY_TOKEN).getAsString();
                        String nickname = jsonObject.get("nickname").getAsString();
                        String header = jsonObject.get("header").getAsString();
                        String userId = jsonObject.get("clientuser_id").getAsString();
                        String jgUserName = jsonObject.get(KEY_JG_USERNAME).getAsString();
                        String jgPwd= jsonObject.get(KEY_JG_PASSWORD).getAsString();
                        String jgNickName = jsonObject.get(KEY_JG_NICKNAME).getAsString();

                        HelperApplication.setJgNickName(jgNickName);
                        HelperApplication.setJgPwd(jgPwd);
                        HelperApplication.setJgName(jgUserName);

                        HelperApplication.setToken(token);
                        HelperApplication.setNickName(nickname);
                        HelperApplication.setHeader(header);
                        HelperApplication.setUserId(userId);
                        if (null != listener) {
                            listener.trans(true);
                        }
                    } catch (Exception e) {
                        onError(e);
                    }
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                LogUtil.log("appLoginWithPwdApi onFail = " + response.getMsg());
                ToastUtil.showShort(response.getMsg());

            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appLoginWithPwdApi onError");
                ToastUtil.showShort("登陆失败");
            }
        });
    }

    /**
     * 验证码登陆
     *
     * @param listener | 回调
     */
    public void appLoginWithCodeApi(final String content,
                                    final TransApiResultListener<Boolean> listener) {
        getApiLoader().postStrObserveJson(APP_LOGIN_WITH_CODE_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appLoginWithCodeApi onSuccess");
                JsonObject jsonObject = response.getData();
                if (null != jsonObject) {
                    LogUtil.log("appLoginWithCodeApi onSuccess = " + jsonObject.toString());
                    String token = jsonObject.get(KEY_TOKEN).getAsString();
                    String nickname = jsonObject.get("nickname").getAsString();
                    String header = jsonObject.get("header").getAsString();
                    String userId = jsonObject.get("clientuser_id").getAsString();
                    String jgUserName = jsonObject.get(KEY_JG_USERNAME).getAsString();
                    String jgPwd= jsonObject.get(KEY_JG_PASSWORD).getAsString();
                    String jgNickName = jsonObject.get(KEY_JG_NICKNAME).getAsString();

                    HelperApplication.setToken(token);
                    HelperApplication.setJgNickName(jgNickName);
                    HelperApplication.setJgPwd(jgPwd);
                    HelperApplication.setJgName(jgUserName);

                    HelperApplication.setNickName(nickname);
                    HelperApplication.setUserId(userId);
                    HelperApplication.setHeader(header);
                    if (listener != null) {
                        listener.trans(true);
                    }
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                LogUtil.log("appLoginWithCodeApi onFail = " + response.getMsg());
                ToastUtil.showShort(response.getMsg());
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appLoginWithCodeApi onError");
            }
        });
    }

    /**
     * 退出登陆
     *
     * @param content  | 传输内容
     * @param listener | 回调
     */
    public void appLogoutApi(final String content,
                             final TransApiResultListener<Boolean> listener) {
        getApiLoader().postStrObserveJson(APP_LOGIN_WITH_PWD_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext) {

        });
    }

    /**
     * CheckCode和短信验证
     *
     * @param content  | 传输内容
     * @param listener | 回调
     */
    public void appMsgCheckApi(final String content,
                               final TransApiResultListener<Boolean> listener) {
        getApiLoader().postStrObserveJson(APP_CHECK_SMS_API.getUrl(), content)
                .subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(
                        mContext) {
                    @Override
                    public void onSuccess(BasicResponse<JsonObject> response) {
                        super.onSuccess(response);
                        LogUtil.log("appMsgCheckApi onSuccess");
                        if (null != listener) {
                            listener.trans(true);
                        }
                    }

                    @Override
                    public void onFail(BasicResponse<JsonObject> response) {
                        super.onFail(response);
                        String msg = response.getMsg();
                        ToastUtil.showLong(msg);
                        LogUtil.log("appMsgCheckApi onFail reason " + msg);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        String msg = e.getMessage();
                        ToastUtil.showLong(msg);
                        LogUtil.log("appMsgCheckApi onError reason " + msg);
                    }
                });
    }

    /**
     * 短信验证后，注册
     *
     * @param content  | 传输内容
     * @param listener | 回调
     */
    public void appRegisterApi(final String content,
                               final TransApiResultListener<Boolean> listener) {
        getApiLoader().postStrObserveJson(APP_REGISTER_API.getUrl(), content)
                .subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(
                        mContext) {
                    @Override
                    public void onSuccess(BasicResponse<JsonObject> response) {
                        super.onSuccess(response);
                        LogUtil.log("appRegisterApi onSuccess");
                        JsonObject data = response.getData();
                        if (null != data) {
                            LogUtil.log("appRegisterApi onSuccess data " + data.toString());
                            String token = data.get(KEY_TOKEN).getAsString();
                            String nickname = data.get("nickname").getAsString();
                            String header = data.get("header").getAsString();
                            String jgUserName = data.get(KEY_JG_USERNAME).getAsString();
                            String jgPwd= data.get(KEY_JG_PASSWORD).getAsString();
                            String jgNickName = data.get(KEY_JG_NICKNAME).getAsString();
                            String userId = data.get("clientuser_id").getAsString();

                            HelperApplication.setJgNickName(jgNickName);
                            HelperApplication.setJgPwd(jgPwd);
                            HelperApplication.setJgName(jgUserName);
                            HelperApplication.setNickName(nickname);
                            HelperApplication.setHeader(header);
                            HelperApplication.setToken(token);
                            HelperApplication.setUserId(userId);
                            if (null != listener) {
                                listener.trans(true);
                            }
                        }
                    }

                    @Override
                    public void onFail(BasicResponse<JsonObject> response) {
                        super.onFail(response);
                        String msg = response.getMsg();
                        ToastUtil.showLong(msg);
                        LogUtil.log("appRegisterApi onFail reason " + msg);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        String msg = e.getMessage();
                        ToastUtil.showLong(msg);
                        LogUtil.log("appRegisterApi onError reason " + msg);
                    }
                });
    }


    /**
     * 发送短信
     *
     * @param content
     * @param listener
     */
    public void appSendSmsApi(final String content,
                              final TransApiResultListener<String> listener) {
        getApiLoader().postStrObserveJson(APP_SEND_SMS_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appSendSmsApi onSuccess");
                JsonObject jsonObject = response.getData();
                if (null != jsonObject) {
                    LogUtil.log("appSendSmsApi onSuccess = " + jsonObject.toString());
                    String checkCode = jsonObject.get(KEY_CHECK_CODE).getAsString();
                    LogUtil.log("appSendSmsApi checkCode = " + checkCode);
                    if (null != listener) {
                        listener.trans(checkCode);
                    }
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                LogUtil.log("appSendSmsApi onFail = " + response.getMsg());
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appSendSmsApi onError");
            }
        });
    }

    /**
     * 设置密码
     *
     * @param content
     * @param listener
     */
    public void appSetUserPwdApi(final String content,
                                 final TransApiResultListener<Boolean> listener) {
        getApiLoader().postStrObserveJson(APP_USER_PWD_SET_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appSetUserPwdApi onSuccess");
                JsonObject jsonObject = response.getData();
                if (null != jsonObject) {
                    LogUtil.log("appSetUserPwdApi onSuccess = " + jsonObject.toString());
                    String token = jsonObject.get(KEY_TOKEN).getAsString();
                    HelperApplication.setToken(token);
                    if (null != listener) {
                        listener.trans(true);
                    }
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                LogUtil.log("appSetUserPwdApi onFail = " + response.getMsg());
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appSetUserPwdApi onError");
            }
        });
    }

    /**
     * 查询资讯列表
     *
     * @param content
     * @param listener
     */
    public void appAllInformation(final String content,
                                  final TransApiResultListener<List<GameInfoItemModel>> listener) {
        getApiLoader().postStrObserveJson(APP_ALL_INFORMATION_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext, false, false, false, false) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appAllInformation onSuccess");
                JsonObject jsonObject = response.getData();
                if (null != jsonObject) {
                    LogUtil.log("appAllInformation onSuccess = " + jsonObject.toString());
                    String msg = response.getMsg();
                    JsonArray jsonArray = jsonObject.getAsJsonArray(KEY_INFORM_LIST);
                    if (null != jsonArray) {
                        int size = jsonArray.size();
                        List<GameInfoItemModel> gameInfoItemModels = new ArrayList<>();
                        if (0 != size) {
                            for (int i = 0; i < size; i++) {
                                JsonObject object = jsonArray.get(i).getAsJsonObject();
                                GameInfoItemModel model = new GameInfoItemModel();
                                String informationId = object.get(KEY_INFORMATION_ID).getAsString();
                                String create_time = object.get(KEY_CREATE_TIME).getAsString();
                                String title = object.get(KEY_TITLE).getAsString();
                                String url = object.get(KEY_URL).getAsString();
                                String commentNum = object.get(KEY_COMMENT_NUM).getAsString();
                                String headerUrl = object.get(KEY_HEAD_URL).getAsString();
                                String clickNum = object.get(KEY_CLICK_NUM).getAsString();
                                if (object.has(KEY_INTRO)) {
                                    String intro = object.get(KEY_INTRO).getAsString();
                                    model.setIntro(intro);
                                }
                                String type = object.get(KEY_TYPE).getAsString();
                                String advertising = object.get(KEY_ADVERTISING_LINK).getAsString();
                                model.setInformationId(informationId);
                                model.setTime(create_time);
                                model.setTitle(title);
                                model.setInfoUrl(url);
                                model.setCheck(clickNum);
                                model.setShareUrl(headerUrl);
                                model.setComment(commentNum);
                                model.setType(type);
                                model.setAdvertising_link(advertising);
                                gameInfoItemModels.add(model);
                            }
                        }
                        if (null != listener) {
                            listener.trans(gameInfoItemModels);
                        }
                    }
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                String msg = response.getMsg();
                LogUtil.log("appAllInformation onFail = " + msg);
                ToastUtil.showShort(msg);
                if (null != listener) {
                    listener.trans(null);
                }
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appAllInformation onError");
                if (null != listener) {
                    listener.trans(null);
                }
            }
        });
    }

    /**
     * 评论资讯
     *
     * @param content
     * @param listener
     */
    public void appCommentInformation(final String content,
                                      final TransApiResultListener<CommentItemModel> listener) {
        getApiLoader().postStrObserveJson(APP_COMMENT_INFORMATION_API.getUrl(), content)
                .subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext) {
                    @Override
                    public void onSuccess(BasicResponse<JsonObject> response) {
                        super.onSuccess(response);
                        JsonObject jsonObject = response.getData();
                        if (null != jsonObject) {
                            LogUtil.log("appCommentInformation onSuccess = " + jsonObject.toString());
                            if (jsonObject.has(KEY_INFOR_COMMENT)) {
                                JsonObject object = jsonObject.getAsJsonObject(KEY_INFOR_COMMENT);
                                if (null != object) {
                                    CommentItemModel commentItemModel = GSonUtil.josnToModel(getGson(), object.toString(), CommentItemModel.class);
                                    if (null != commentItemModel) {
                                        if (null != listener) {
                                            listener.trans(commentItemModel);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    @Override
                    public void onFail(BasicResponse<JsonObject> response) {
                        super.onFail(response);
                        String msg = response.getMsg();
                        ToastUtil.showShort(msg);
                        LogUtil.log("appCommentInformation onFail = " + msg);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        LogUtil.log("appCommentInformation onError");
                    }
                });
    }

    /**
     * 给评论点赞
     *
     * @param content
     * @param listener
     */
    public void appThumb(final String content,
                         final TransApiResultListener<String> listener) {
        getApiLoader().postStrObserveJson(APP_THUMB_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appThumb onSuccess");
                JsonObject jsonObject = response.getData();
                String msg = response.getMsg();
                if (null != jsonObject) {
                    if (jsonObject.has(KEY_THUMB_NUM)) {
                        String thumbNum = jsonObject.get(KEY_THUMB_NUM).getAsString();
                        LogUtil.log("appThumb onSuccess = " + jsonObject.toString() + " thumbNum = " + thumbNum + " msg = " + msg);
                        ToastUtil.showShort(msg);
                        if (null != listener) {
                            listener.trans(thumbNum);
                        }
                    }
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                String msg = response.getMsg();
                ToastUtil.showShort(msg);
                LogUtil.log("appThumb onFail = " + msg);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appThumb onError");
            }
        });
    }

    /**
     * 取消点赞
     *
     * @param content
     * @param listener
     */
    public void appCancelThumb(final String content,
                               final TransApiResultListener<String> listener) {
        getApiLoader().postStrObserveJson(APP_CANCEL_THUMB_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                JsonObject jsonObject = response.getData();
                String msg = response.getMsg();
                if (null != jsonObject) {
                    if (jsonObject.has(KEY_THUMB_NUM)) {
                        String thumbNum = jsonObject.get(KEY_THUMB_NUM).getAsString();
                        LogUtil.log("appCancelThumb onSuccess = " + jsonObject.toString() + " thumbNum = " + thumbNum + " msg = " + msg);
                        ToastUtil.showShort(msg);
                        if (null != listener) {
                            listener.trans(thumbNum);
                        }
                    }
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                String msg = response.getMsg();
                ToastUtil.showShort(msg);
                LogUtil.log("appCancelThumb onFail = " + msg);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appCancelThumb onError");
            }
        });
    }

    /**
     * 资讯详情
     *
     * @param content
     * @param listener
     */
    public void appAllInformationDetail(final String content,
                                        final TransApiResultListener<GameDetailModel> listener) {
        getApiLoader().postStrObserveJson(APP_INFORMATION_DETAIL_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext, false, false, true, false) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                JsonObject jsonObject = response.getData();
                LogUtil.log("appAllInformationDetail onSuccess");
                if (null != jsonObject && jsonObject.has(KEY_COMMENT_LIST)) {
                    LogUtil.log("appAllInformationDetail onSuccess = " + jsonObject.toString());
                    JsonArray jsonArray = jsonObject.getAsJsonArray(KEY_COMMENT_LIST);
                    int size = jsonArray.size();
                    GameDetailModel gameDetailModel = new GameDetailModel();
                    if (0 < size) {
                        List<CommentItemModel> listCommentItemModel = new ArrayList<>();
                        for (int i = 0; i < size; i++) {
                            CommentItemModel commentItemModel = new CommentItemModel();
                            JsonObject object = jsonArray.get(i).getAsJsonObject();
                            String create_time = object.get(KEY_CREATE_TIME).getAsString();
                            String nickname = object.get(KEY_NICK_NAME).getAsString();
                            String header = object.get(KEY_HEADER).getAsString();
                            String thumb = object.get(KEY_THUMB).getAsString();
                            String content = object.get(KEY_CONTENT).getAsString();
                            String thumbNum = object.get(KEY_THUMB_NUM).getAsString();
                            String informationcomment_id = object.get(KEY_INFORMATION_COMMENT_ID).getAsString();
                            commentItemModel.setIsLike(thumb);
                            commentItemModel.setLike(thumbNum);
                            commentItemModel.setComment(content);
                            commentItemModel.setTime(create_time);
                            commentItemModel.setTitle(nickname);
                            commentItemModel.setImgUrl(header);
                            commentItemModel.setCommentId(informationcomment_id);
                            listCommentItemModel.add(commentItemModel);
                        }
                        gameDetailModel.setListCommentItemModel(listCommentItemModel);
                    }
                    String headurl = jsonObject.get(KEY_HEAD_URL).getAsString();
                    String title = jsonObject.get(KEY_TITLE).getAsString();
                    gameDetailModel.setImgUrl(headurl);
                    gameDetailModel.setTitle(title);
                    if (null != listener) {
                        listener.trans(gameDetailModel);
                    }
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                String msg = response.getMsg();
                LogUtil.log("appAllInformationDetail onFail = " + msg);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appAllInformationDetail onError");
            }
        });
    }

    /**
     * 获取轮播图
     *
     * @param content
     * @param listener
     */
    public void appGetViewPage(final String content,
                               final TransApiResultListener<List<String>> listener) {
        getApiLoader().postStrObserveJson(APP_GET_VIEW_PAGE_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appGetViewPage onSuccess");
                JsonObject jsonObject = response.getData();
                String msg = response.getMsg();
                if (null != jsonObject && jsonObject.has(KEY_SRC_LIST)) {
                    LogUtil.log("appGetViewPage onSuccess = " + jsonObject.toString());
                    JsonArray jsonArray = jsonObject.getAsJsonArray(KEY_SRC_LIST);
                    if (jsonArray != null) {
                        int size = jsonArray.size();
                        List<String> list = new ArrayList<>();
                        if (size > 0) {
                            for (int i = 0; i < size; i++) {
                                JsonObject object = jsonArray.get(i).getAsJsonObject();
                                String src = object.get(KEY_SRC).getAsString();
                                list.add(src);
                            }
                        }
                        ToastUtil.showShort(msg);
                        if (null != listener) {
                            listener.trans(list);
                        }
                    }
                }

            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                String msg = response.getMsg();
                ToastUtil.showShort(msg);
                LogUtil.log("appGetViewPage onFail = " + msg);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appGetViewPage onError");
            }
        });
    }

    /**
     * 获取游戏logo列表
     *
     * @param content
     * @param listener
     */
    public void appGetMyCompetitionGameList(final String content,
                                            final TransApiResultListener<List<MatchGameItemModel>> listener) {
        getApiLoader().postStrObserveJson(APP_MY_COMPETITION_GAME_LIST_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appGetMyCompetitionGameList onSuccess");
                JsonObject jsonObject = response.getData();
                if (null != jsonObject && jsonObject.has(KEY_GAME_LIST)) {
                    LogUtil.log("appGetMyCompetitionGameList onSuccess = " + jsonObject.toString());
                    JsonArray jsonArray = jsonObject.getAsJsonArray(KEY_GAME_LIST);
                    if (jsonArray != null) {
                        int size = jsonArray.size();
                        List<MatchGameItemModel> list = new ArrayList<>();
                        if (size > 1) {
                            for (int i = 0; i < size; i++) {
                                JsonObject object = jsonArray.get(i).getAsJsonObject();
                                MatchGameItemModel matchGameItemModel = new MatchGameItemModel();
                                String name = object.get(KEY_NAME).getAsString();
                                if (object.has(KEY_GAME_ID)) {
                                    String game_id = object.get(KEY_GAME_ID).getAsString();
                                    matchGameItemModel.setGameId(game_id);
                                }
                                if (object.has(KEY_LOGO)) {
                                    String logo = object.get(KEY_LOGO).getAsString();
                                    matchGameItemModel.setLogo(logo);
                                }
                                matchGameItemModel.setName(name);
                                list.add(matchGameItemModel);
                            }
                            if (null != listener) {
                                listener.trans(list);
                            }
                        }
                    }
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                String msg = response.getMsg();
                ToastUtil.showShort(msg);
                LogUtil.log("appGetMyCompetitionGameList onFail = " + msg);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appGetMyCompetitionGameList onError");
            }
        });
    }

    /**
     * 获取历史搜索关键词
     *
     * @param content
     * @param listener
     */
    public void appGetOrderWords(final String content,
                                 final TransApiResultListener<ArrayList<String>> listener) {
        getApiLoader().postStrObserveJson(APP_GET_ORDER_WORDS_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appGetOrderWords onSuccess");
                JsonObject jsonObject = response.getData();
                String msg = response.getMsg();
                if (null != jsonObject && jsonObject.has(KEY_WORDS)) {
                    LogUtil.log("appGetOrderWords onSuccess = " + jsonObject.toString());
                    JsonArray jsonArray = jsonObject.getAsJsonArray(KEY_WORDS);
                    if (jsonArray != null) {
                        int size = jsonArray.size();
                        ArrayList<String> list = new ArrayList<>();
                        if (size > 0) {
                            for (int i = 0; i < size; i++) {
                                JsonObject object = jsonArray.get(i).getAsJsonObject();
                                String word = object.get(KEY_WORDS).getAsString();
                                list.add(word);
                            }
                            if (null != listener) {
                                listener.trans(list);
                            }
                        }
                    }
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                String msg = response.getMsg();
                ToastUtil.showShort(msg);
                LogUtil.log("appGetOrderWords onFail = " + msg);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appGetOrderWords onError");
            }
        });
    }

    /**
     * 关键词模糊查询
     *
     * @param content
     * @param listener
     */
    public void appGetNameAndTitle(final String content,
                                   final TransApiResultListener<List<String>> listener) {
        getApiLoader().postStrObserveJson(APP_GET_NAME_TITLE_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext, false, false, true, false) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appGetNameAndTitle onSuccess");
                JsonObject jsonObject = response.getData();
                if (null != jsonObject && jsonObject.has(KEY_WORDS)) {
                    LogUtil.log("appGetNameAndTitle onSuccess = " + jsonObject.toString());
                    JsonArray jsonArray = jsonObject.getAsJsonArray(KEY_WORDS);
                    if (jsonArray != null) {
                        int size = jsonArray.size();
                        List<String> list = new ArrayList<>();
                        if (size > 0) {
                            for (int i = 0; i < size; i++) {
                                JsonObject object = jsonArray.get(i).getAsJsonObject();
                                String word = object.get(KEY_WORD).getAsString();
                                list.add(word);
                            }
                            if (null != listener) {
                                listener.trans(list);
                            }
                        }
                    }
                }

            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                String msg = response.getMsg();
                LogUtil.log("appGetNameAndTitle onFail = " + msg);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appGetNameAndTitle onError");
            }
        });
    }

    /**
     * 关键词查询
     *
     * @param content
     * @param listener
     */
    public void appGetHomeSearchByWord(final String content,
                                       final TransApiResultListener<List<GameInfoItemModel>> listener) {
        getApiLoader().postStrObserveJson(APP_GET_SEARCH_BYWORD_API.getUrl(), content)
                .subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext) {
                    @Override
                    public void onSuccess(BasicResponse<JsonObject> response) {
                        super.onSuccess(response);
                        LogUtil.log("appGetHomeSearchByWord onSuccess");
                        JsonObject jsonObject = response.getData();
                        String msg = response.getMsg();
                        if (null != jsonObject && jsonObject.has(KEY_ANTISTOP_LIST)) {
                            LogUtil.log("appGetHomeSearchByWord onSuccess = " + jsonObject.toString());
                            JsonArray jsonArray = jsonObject.getAsJsonArray(KEY_ANTISTOP_LIST);
                            if (jsonArray != null) {
                                int size = jsonArray.size();
                                LogUtil.log("appGetHomeSearchByWord onSuccess size = " + size);
                                if (0 != size) {
                                    List<GameInfoItemModel> gameInfoItemModels = new ArrayList<>();
                                    for (int i = 0; i < size; i++) {
                                        JsonObject object = jsonArray.get(i).getAsJsonObject();
                                        GameInfoItemModel model = new GameInfoItemModel();
                                        String informationId = object.get(KEY_INFORMATION_ID).getAsString();
                                        String create_time = object.get(KEY_CREATE_TIME).getAsString();
                                        String title = object.get(KEY_TITLE).getAsString();
                                        String url = object.get(KEY_URL).getAsString();
                                        String commentNum = object.get(KEY_COMMENT_NUM).getAsString();
                                        String headerUrl = object.get(KEY_HEAD_URL).getAsString();
                                        String clickNum = object.get(KEY_CLICK_NUM).getAsString();
                                        model.setInformationId(informationId);
                                        model.setTime(create_time);
                                        model.setTitle(title);
                                        model.setInfoUrl(url);
                                        model.setCheck(clickNum);
                                        model.setShareUrl(headerUrl);
                                        model.setComment(commentNum);
                                        gameInfoItemModels.add(model);
                                    }
                                    ToastUtil.showShort(msg);
                                    if (null != listener) {
                                        listener.trans(gameInfoItemModels);
                                    }
                                }
                            }
                        }
                    }

                    @Override
                    public void onFail(BasicResponse<JsonObject> response) {
                        super.onFail(response);
                        String msg = response.getMsg();
                        ToastUtil.showShort(msg);
                        LogUtil.log("appGetHomeSearchByWord onFail = " + msg);
                        if (null != listener) {
                            listener.trans(null);
                        }
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        LogUtil.log("appGetHomeSearchByWord onError");
                        if (null != listener) {
                            listener.trans(null);
                        }
                    }
                });
    }

    /**
     * 创建比赛
     *
     * @param content
     * @param listener
     */
    public void appCreateCompetition(final String content,
                                     final TransApiResultListener<String> listener) {
        getApiLoader().postStrObserveJson(APP_CREATE_COMPETITION_API.getUrl(), content).subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(mContext, false, false, true, false) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                String msg = response.getMsg();
                LogUtil.log("appCreateCompetition onSuccess msg = " + msg);
                if (null != listener) {
                    listener.trans(msg);
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                String msg = response.getMsg();
                LogUtil.log("appCreateCompetition onFail = " + msg);
                ToastUtil.showShort(msg);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appCreateCompetition onError");
            }
        });
    }

    /**
     * 获取帖子列表
     */
    public void appGetTopicList(final String content,
                                final TransApiResultListener<List<PostModel>> listener) {
        getApiLoader().postStrObserveJson(APP_GET_TOPIC_LIST.getUrl(), content)
                .subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(
                        mContext, false, false, true, false) {
                    @Override
                    public void onSuccess(BasicResponse<JsonObject> response) {
                        super.onSuccess(response);
                        JsonObject jsonObject = response.getData();
                        if (null != jsonObject && jsonObject.has(KEY_TOPIC_LIST)) {
                            LogUtil.log("appGetTopicList onSuccess = " + jsonObject.toString());
                            List<PostModel> postList = getGson().fromJson(jsonObject.getAsJsonArray(KEY_TOPIC_LIST),
                                    new TypeToken<List<PostModel>>() {
                                    }.getType());
                            if (null != listener) {
                                listener.trans(postList);
                            }
                        }

                    }

                    @Override
                    public void onFail(BasicResponse<JsonObject> response) {
                        super.onFail(response);
                        String msg = response.getMsg();
                        LogUtil.log("appGetTopicList onFail = " + msg);
                        if (null != listener) {
                            listener.trans(null);
                        }
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        LogUtil.log("appGetTopicList onError");
                        if (null != listener) {
                            listener.trans(null);
                        }
                    }
                });
    }

    /***
     * 发帖
     */
    public void appPublishTopic(String content, final TransApiResultListener<JsonObject> listener) {
        Observer<? super BasicResponse<JsonObject>> observer = new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(
                mContext, false, false, true, false) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appPublishTopic onSuccess");
                JsonObject jsonObject = response.getData();
                if (null != listener) {
                    listener.trans(jsonObject);
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                String msg = response.getMsg();
                LogUtil.log("appPublishTopic onFail = " + msg);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appPublishTopic onError");
            }
        };
        getApiLoader().postStrObserveJson(ApiEnum.APP_PUBLISH_TOPIC.getUrl(), content)
                .subscribe(observer);
    }

    /**
     * 获取帖子评论回复列表分页
     */
    public void appGetReplyList(String content, final TransApiResultListener<List<CommentModel>> listener) {
        Observer<? super BasicResponse<JsonObject>> observer = new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(
                mContext, false, false, true, false) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appGetReplyList onSuccess");
                JsonObject jsonObject = response.getData();

                if (null != jsonObject && jsonObject.has(KEY_COMMENT_LIST)) {
                    LogUtil.log("appGetReplyList onSuccess = " + jsonObject.toString());
                    List<CommentModel> list = getGson().fromJson(jsonObject.getAsJsonArray(KEY_COMMENT_LIST),
                            new TypeToken<List<CommentModel>>() {
                            }.getType());
                    if (null != listener) {
                        listener.trans(list);
                    }
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                String msg = response.getMsg();
                LogUtil.log("appGetReplyList onFail = " + msg);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appGetReplyList onError");
            }
        };
        getApiLoader().postStrObserveJson(ApiEnum.APP_GET_REPLY_LIST.getUrl(), content)
                .subscribe(observer);
    }

    public void appAddShareLog(String content, final TransApiResultListener<Integer> listener) {
        Observer<? super BasicResponse<JsonObject>> observer = new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(
                mContext, false, false, true, false) {
            @Override
            public void onSuccess(BasicResponse<JsonObject> response) {
                super.onSuccess(response);
                LogUtil.log("appAddShareLog onSuccess");
                JsonObject data = response.getData();

                if (null != listener) {
                    listener.trans(data.getAsInt());
                }
            }

            @Override
            public void onFail(BasicResponse<JsonObject> response) {
                super.onFail(response);
                String msg = response.getMsg();
                LogUtil.log("appAddShareLog onFail = " + msg);
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                LogUtil.log("appAddShareLog onError");
            }
        };
        getApiLoader().postStrObserveJson(ApiEnum.APP_ADD_SHARE_LOG.getUrl(), content)
                .subscribe(observer);
    }

    //我的接口

    /**
     * 获取个人数据
     */
    public void getMyInformationDetail(final String content,
                                       final TransApiResultListener<SettingBasicInfo> listener) {
        getApiLoader().postStrObserveJson(APP_MY_INFORMATION_DETAIL_API.getUrl(), content)
                .subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(
                        mContext, false, false, true, false) {
                    @Override
                    public void onSuccess(BasicResponse<JsonObject> response) {
                        super.onSuccess(response);
                        JsonObject jsonObject = response.getData();
                        if (null != jsonObject && jsonObject.has(KEY_USER)) {
                            LogUtil.log("getMyInformationDetail onSuccess = " + jsonObject.toString());
                            SettingBasicInfo basicInfo = getGson().fromJson(jsonObject.getAsJsonObject(KEY_USER),
                                    new TypeToken<SettingBasicInfo>() {
                                    }.getType());
                            if (null != listener) {
                                listener.trans(basicInfo);
                            }
                        }
                    }

                    @Override
                    public void onFail(BasicResponse<JsonObject> response) {
                        super.onFail(response);
                        String msg = response.getMsg();
                        LogUtil.log("getMyInformationDetail onFail = " + msg);
                        if (null != listener) {
                            listener.trans(null);
                        }
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        LogUtil.log("getMyInformationDetail onError");
                        if (null != listener) {
                            listener.trans(null);
                        }
                    }
                });
    }

    /**
     * 获取用户关注列表
     */
    public void getUserAttentionList(final String content,
                                     final TransApiResultListener<SettingBasicInfo> listener) {
        getApiLoader().postStrObserveJson(APP_GET_USER_ATTENTION_LIST_API.getUrl(), content)
                .subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(
                        mContext, false, false, true, false) {
                    @Override
                    public void onSuccess(BasicResponse<JsonObject> response) {
                        super.onSuccess(response);
                        LogUtil.log("getUserAttentionList onSuccess");
                        JsonObject jsonObject = response.getData();
                        if (null != jsonObject && jsonObject.has(KEY_USER)) {
                            LogUtil.log("getUserAttentionList onSuccess = " + jsonObject.toString());
                            SettingBasicInfo basicInfo = getGson().fromJson(jsonObject.getAsJsonObject(KEY_USER),
                                    new TypeToken<SettingBasicInfo>() {
                                    }.getType());
                            if (null != listener) {
                                listener.trans(basicInfo);
                            }
                        }
                    }

                    @Override
                    public void onFail(BasicResponse<JsonObject> response) {
                        super.onFail(response);
                        String msg = response.getMsg();
                        LogUtil.log("getUserAttentionList onFail = " + msg);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        LogUtil.log("getUserAttentionList onError");
                    }
                });
    }

    /**
     * 获取收藏列表
     */
    public void getUserCollectList(final String content,
                                   final TransApiResultListener<SettingBasicInfo> listener) {
        getApiLoader().postStrObserveJson(APP_GET_USER_COLLECT_LIST_API.getUrl(), content)
                .subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(
                        mContext, false, false, true, false) {
                    @Override
                    public void onSuccess(BasicResponse<JsonObject> response) {
                        super.onSuccess(response);
                        LogUtil.log("getUserCollectList onSuccess");
                        JsonObject jsonObject = response.getData();
                        if (null != jsonObject && jsonObject.has(KEY_USER)) {
                            LogUtil.log("getUserCollectList onSuccess = " + jsonObject.toString());
                            SettingBasicInfo basicInfo = getGson().fromJson(jsonObject.getAsJsonObject(KEY_USER),
                                    new TypeToken<SettingBasicInfo>() {
                                    }.getType());
                            if (null != listener) {
                                listener.trans(basicInfo);
                            }
                        }
                    }

                    @Override
                    public void onFail(BasicResponse<JsonObject> response) {
                        super.onFail(response);
                        String msg = response.getMsg();
                        LogUtil.log("getUserCollectList onFail = " + msg);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        LogUtil.log("getUserCollectList onError");
                    }
                });
    }

    /**
     * 创建战队
     */
    public void appCreateTeam(final String content,
                              final TransApiResultListener<Boolean> listener) {
        getApiLoader().postStrObserveJson(APP_CREATE_TEAM.getUrl(), content)
                .subscribe(new RetrofitBasicResponseObserver<BasicResponse<JsonObject>>(
                        mContext, true, true, true, true) {
                    @Override
                    public void onSuccess(BasicResponse<JsonObject> response) {
                        super.onSuccess(response);
                        JsonObject jsonObject = response.getData();
                        LogUtil.log("appCreateTeam onSuccess = " + jsonObject.toString());
                        if (null != listener) {
                            listener.trans(true);
                        }
                    }

                    @Override
                    public void onFail(BasicResponse<JsonObject> response) {
                        super.onFail(response);
                        String msg = response.getMsg();
                        ToastUtil.showShort(msg);
                        LogUtil.log("appCreateTeam onFail = " + msg);
                        if (null != listener) {
                            listener.trans(false);
                        }
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        LogUtil.log("appCreateTeam onError msg = " + e.getMessage());
                        if (null != listener) {
                            listener.trans(false);
                        }
                    }
                });
    }

    @Override
    protected void showLog(final String type, final String content) {
        showLog(type + " : " + content);
    }

    private static class Holder {
        @SuppressLint("StaticFieldLeak")
        private static final ApiHelper M_HELPER = new ApiHelper();
    }
}
